package com.ldx.java_chatroom.service;

import com.ldx.java_chatroom.mapper.MessageMapper;
import com.ldx.java_chatroom.model.Message;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

@Service
public class MessageService {
    @Resource
    MessageMapper messageMapper;

    public Object getMessagesBySessionId(int sessionId) {
        List<Message> messages = messageMapper.getMessagesBySessionId(sessionId);
        Collections.reverse(messages);
        return messages;
    }
}
